package com.umeox.watch.moto.contact.ui;


import static com.umeox.watch.moto.agora.InternalConstants.CallType.OUTGOING_VIDEO_CALL;
import static io.agora.rtc.Constants.QUALITY_BAD;
import static io.agora.rtc.Constants.QUALITY_DOWN;
import static io.agora.rtc.Constants.QUALITY_VBAD;

import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemClock;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;

import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.tencent.mmkv.MMKV;
import com.umeox.moto.common.executor.ThreadExecutor;
import com.umeox.moto.common.log.Logger;
import com.umeox.moto.common.utils.DeviceManager;
import com.umeox.moto.watch.themes.app.ThemeAppCompatActivity;
import com.umeox.moto.watch.themes.skin.loader.ResourceManager;
import com.umeox.moto.watch.themes.util.UToast;
import com.umeox.moto.watch.themes.widget.RoundedImageView;
import com.umeox.watch.moto.agora.AgoraService;
import com.umeox.watch.moto.agora.InternalConstants;
import com.umeox.watch.moto.apiclient.model.VoipTokenDTO;
import com.umeox.watch.moto.contact.BuildConfig;
import com.umeox.watch.moto.contact.R;
import com.umeox.watch.moto.contact.base.GlideApp;
import com.umeox.watch.moto.contact.model.CallLog;
import com.umeox.watch.moto.contact.model.ContactDetail;
import com.umeox.watch.moto.contact.receiver.PhoneStateReceiver;
import com.umeox.watch.moto.contact.utils.Utils;
import com.umeox.watch.moto.dataservice.DataProvider;
import com.umeox.watch.moto.dataservice.constants.Constants;
import com.umeox.watch.moto.dataservice.proxy.VideocallProxy;

import java.util.Locale;
import java.util.concurrent.TimeUnit;

import io.agora.rtc.RtcEngine;

public class OutgoingCallActivity extends ThemeAppCompatActivity implements View.OnClickListener, PhoneStateReceiver.PhoneStateListener, AgoraService.RtcEventChangeListener, AgoraService.RemoteVideoStateChangedLister, VolumeSettingDialog.OnVolumeChangeListener {

    private FrameLayout renderLayout;
    private ImageView ivHangup, ivVolume, mSwitchIv;
    private TextView tvDuration, mCallingTv, tvNickname, mMicrophoneIv;
    private VolumeSettingDialog volumeSettingDialog;
    //constant
    private String mChannel, peer, friendId;
    private ContactDetail contact;

    private RoundedImageView mAvatarIv;

    //flag
    private boolean isAnswer = false;//对方是否接听

    private VideocallProxy videoCallBinder;

    private AgoraService mAgoraService;
    private AudioManager mAudioManager;

    private boolean mIsVoiceCall;
    private int mUid;

    private boolean isSwitch2Video;

    private VoipTokenDTO voipTokenDTO;

    private MediaPlayer player;
    private boolean peerHangupReceiverIsRegister;
    private View mControlView;

    private int mCurrentVolume;
    private boolean mOriginalRaiseUpOn;
    private boolean mOriginalisOverlayScreenOn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        mAudioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        Intent intent = getIntent();
        Uri uri = intent.getData();
        if (uri != null) {
            friendId = uri.getQueryParameter(InternalConstants.CALL_QUERY_PARA_FOLLOWER_ID);
            mIsVoiceCall = InternalConstants.CALL_TYPE_VOICE.equals(uri.getPath());
        }
        if (TextUtils.isEmpty(friendId)) {
            logger("被叫方ID为空，退出应用");
            finish();
            return;
        }

        contact = Utils.getContactByFriendId(friendId);
        if (contact == null) {
            logger("没有找到联系人，退出应用");
            finish();
            return;
        }

        setContentView(R.layout.act_outgoing);
        mAgoraService = AgoraService.Companion.getInstance(this);
        mAgoraService.setCallType(mIsVoiceCall ? AgoraService.CALL_TYPE_VOICE : AgoraService.CALL_TYPE_VIDEO);
        mAgoraService.setFriendId(friendId);
        mAgoraService.setEventHandler(this);
        mAgoraService.setRemoteVideoStateChangedListener(this);
        mChannel = friendId + "_" + System.currentTimeMillis();
        peer = friendId;
        videoCallBinder = (VideocallProxy) VideocallProxy.fetchBinder();
        initView();

        renderLayout.postDelayed(mStartRingtoneRunnable, 2000);

        registerPeerHangupReceiver();
        Settings.Global.putInt(getContentResolver(), "isInVideoCall", 1);
        mOriginalRaiseUpOn = DeviceManager.getInstance().isRaiseUpOn();
        mOriginalisOverlayScreenOn = DeviceManager.getInstance().isOverlayScreenOn();
    }


    private final Runnable mStartRingtoneRunnable = OutgoingCallActivity.this::startRingtone;


    private void registerPeerHangupReceiver() {
        final IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Constants.ACTION_CANCEL_AGORA_CALL);
        registerReceiver(mPeerHangupReceiver, intentFilter);
        peerHangupReceiverIsRegister = true;
    }

    private final BroadcastReceiver mPeerHangupReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            if (action == null) {
                return;
            }
            String channel = intent.getStringExtra("channel");
            if (channel.equals(mChannel)) {
                if (!isAnswer) {
                    finish();
                }
            }

        }
    };

    private final Runnable mInviteTasks = new Runnable() {
        @Override
        public void run() {
            if (!isAnswer) {
                ThreadExecutor.getInstance().io().execute(() -> logger("通知服务器取消邀请>>>" + (mIsVoiceCall ? notifyCancelVoip() : notifyCancelVideo())));
            }
            mAgoraService.endCall();
        }
    };

    @Override
    protected void onPostCreate(@Nullable Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        //发送广播通知监听视频来电的应用，目前处于视频通话状态
        sendBroadcast(new Intent(Constants.ACTION_RINGING_VIDEO_CALL));
        PhoneStateReceiver.registerPhoneStateReceiver(this, this);

        if (renderLayout != null) {
            renderLayout.postDelayed(mInviteTasks, TimeUnit.MINUTES.toMillis(1));
        }
        //目前登录需要Token，所以要先拿Token
        ThreadExecutor.getInstance().io().execute(() -> {
            try {
                voipTokenDTO = videoCallBinder.getVoipToken(DataProvider.getHolderId(), friendId, mChannel);
                if (voipTokenDTO != null) {
                    logger("voipTokenDTO:" + voipTokenDTO);
                    peer = voipTokenDTO.rtmToMemberId;
                    mAgoraService.login(voipTokenDTO.rtmFromMemberId, voipTokenDTO.rtmToken);
                }
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        });
    }

    @SuppressLint("CheckResult")
    private void initView() {
        renderLayout = findViewById(R.id.renderLayout);

        tvNickname = findViewById(R.id.tvNickname);
        mCallingTv = findViewById(R.id.tvDuration);
        tvDuration = findViewById(R.id.tv_duration);
        ivHangup = findViewById(R.id.ivHangup);
        ivVolume = findViewById(R.id.ivVolume);
        mSwitchIv = findViewById(R.id.camera_switch_iv);
        mControlView = findViewById(R.id.ll_control);
        mMicrophoneIv = findViewById(R.id.iv_microphone);
        mAvatarIv = findViewById(R.id.avatar);

        mCurrentVolume = Utils.getVolume(this);
        if (mCurrentVolume == 0) {
            ivVolume.setImageDrawable(mIsVoiceCall ? ResourceManager.getInstance().getDrawable(R.drawable.ic_volume_mute) : ResourceManager.getInstance().getDrawable(R.drawable.ic_volume_video_mute));
        } else {
            ivVolume.setImageDrawable(mIsVoiceCall ? ResourceManager.getInstance().getDrawable(R.drawable.ic_volume) : ResourceManager.getInstance().getDrawable(R.drawable.ic_volume_video));
        }


        renderLayout.setOnClickListener(this);
        ivHangup.setOnClickListener(this);
        ivVolume.setOnClickListener(this);
        mSwitchIv.setOnClickListener(this);
        mMicrophoneIv.setOnClickListener(this);

        tvNickname.setText(contact.getContactName());
        final Drawable callTypeDrawable = ResourcesCompat.getDrawable(getResources(), mIsVoiceCall ? R.drawable.contact_voice : R.drawable.contact_video, null);
        mCallingTv.setCompoundDrawablesRelativeWithIntrinsicBounds(callTypeDrawable, null, null, null);
        mCallingTv.setText(getResources().getString(R.string.calling));

        GlideApp.with(this)
                .load(contact.getContactPhotoUrl())
                .placeholder((R.drawable.default_avatar))
                .error(R.drawable.default_avatar)
                .apply(RequestOptions.bitmapTransform(new CircleCrop()))
                .into(mAvatarIv);


    }

    /**
     * 收到语音电话来电广播
     */
    @Override
    public void onCallStateRinging() {
        stopRingtone();
        mAgoraService.endCall();
    }

    /**
     * 收到关机广播
     */
    @Override
    public void onShutdown() {
        stopRingtone();
        mAgoraService.endCall();
    }

    @Override
    public void onBackPressed() {
//        stopRingtone();
//        mAgoraService.endCall();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ivHangup:
                stopRingtone();
//                if (!isAnswer) {
                ThreadExecutor.getInstance().io().execute(() -> logger("通知服务器取消邀请>>>" + (mIsVoiceCall ? notifyCancelVoip() : notifyCancelVideo())));
//                }
                mAgoraService.endCall();
                finish();
                break;
            case R.id.ivVolume:
                if (volumeSettingDialog == null) {
                    volumeSettingDialog = new VolumeSettingDialog(this, isAnswer);
                }
                volumeSettingDialog.setIsAnswer(isAnswer);
                volumeSettingDialog.setOnVolumeChangeListener(OutgoingCallActivity.this);
                volumeSettingDialog.show();
                break;
            case R.id.renderLayout:
                if (!isAnswer) {
                    return;
                }
//                if (mControlView.getVisibility() == View.GONE) {
//                    slideInNow();
//                }

                break;
            case R.id.camera_switch_iv:
                mAgoraService.switchCamera();
                break;
            case R.id.iv_microphone:
                mMicrophoneIv.setSelected(!mMicrophoneIv.isSelected());
                mAgoraService.muteLocalAudioStream(mMicrophoneIv.isSelected());
                break;
            default:
                break;
        }
    }


    private void slideInNow() {
        tvDuration.setVisibility(View.VISIBLE);
        mControlView.setVisibility(View.VISIBLE);
        mControlView.removeCallbacks(action);
        mControlView.postDelayed(action, 5000);
    }


    Runnable action = new Runnable() {
        @Override
        public void run() {
            mControlView.setVisibility(View.GONE);
            tvDuration.setVisibility(View.GONE);
        }

    };


    private int inviteJoinVideo(String friendId, String channel) {
        if (videoCallBinder != null) {
            try {
                return videoCallBinder.inviteJoinVideo(friendId, channel);
            } catch (Exception e) {
                e.printStackTrace();

                Logger.e("invite join video call failed：" + e);
            }
        }
        return -1;
    }

    private int inviteJoinVoip(String friendId, String channel) {
        if (videoCallBinder != null) {
            try {
                return videoCallBinder.inviteJoinVoip(friendId, channel);
            } catch (Exception e) {
                e.printStackTrace();
                Logger.e("invite join voice call failed：" + e);
            }
        }
        return -1;
    }

    /**
     * 通过aidl调用api通知app取消当前通话
     */
    public boolean notifyCancelVideo() {
        if (videoCallBinder != null) {
            try {
                return videoCallBinder.notifyCancelVideo(friendId, mChannel);
            } catch (Exception e) {
                e.printStackTrace();
                Logger.e("notify cancel video call failed：" + e);
            }
        }
        return false;
    }

    /**
     * 通过aidl调用api通知app取消当前通话
     */
    public boolean notifyCancelVoip() {
        if (videoCallBinder != null) {
            try {
                return videoCallBinder.notifyCancelVoip(friendId, mChannel);
            } catch (Exception e) {
                e.printStackTrace();
                Logger.e("notify cancel voice call failed：" + e);
            }
        }
        return false;
    }

    /**
     * 通过aidl调用api，上报本次通话时长
     */
    public boolean uploadVideoTime(long totalDuration) {
        if (videoCallBinder != null) {
            try {
                return videoCallBinder.uploadVideoTime(friendId, mChannel, totalDuration, System.currentTimeMillis());
            } catch (Exception e) {
                Logger.e("invite join video call failed：" + e);
            }
        }
        return false;
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        logger("onDestroy: " + this);
        Settings.Global.putInt(getContentResolver(), "isInVideoCall", 0);
        if (mOriginalRaiseUpOn) {
            DeviceManager.getInstance().setRaiseUpValue(true);
        }
        if (mOriginalisOverlayScreenOn) {
            DeviceManager.getInstance().setOverlayScreenValue(true);
        }
        renderLayout.removeCallbacks(mInviteTasks);
//        mControlView.removeCallbacks(action);
        stopRingtone();
        mAgoraService.resetCallState();
        mAgoraService.setEventHandler(null);
        mAudioManager.abandonAudioFocus(null);
        AsyncTask.execute(RtcEngine::destroy);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        PhoneStateReceiver.unRegisterPhoneStateReceiver(this);
        if (peerHangupReceiverIsRegister && mPeerHangupReceiver != null) {
            unregisterReceiver(mPeerHangupReceiver);
            peerHangupReceiverIsRegister = false;
        }
        renderLayout.removeCallbacks(mStartRingtoneRunnable);

    }

    private void logger(String text) {
        Logger.w(text);
    }


    @Override
    public void onLoggedIn() {
        try {

            logger("登录信令成功，开始邀请APP端");
            int result = mIsVoiceCall ? inviteJoinVoip(friendId, mChannel) : inviteJoinVideo(friendId, mChannel);

            logger("邀请结果>>>" + result);
            switch (result) {
                case 0:
                    mAgoraService.inviteCall(mChannel, peer, voipTokenDTO.channelToken, voipTokenDTO.rtcMemberId);
                    return;
                case 40405:
                    runOnUiThread(() -> Toast.makeText(this, R.string.call_in_class_mode, Toast.LENGTH_SHORT).show());
                    logger("对方正在上课模式，即将退出");
                    break;
                case 40406:
                    runOnUiThread(() -> Toast.makeText(this, R.string.call_device_offline, Toast.LENGTH_SHORT).show());
                    logger("对方不在线，即将退出");
                    break;
                default:
                    runOnUiThread(() -> Toast.makeText(this, R.string.call_send_request_fail, Toast.LENGTH_SHORT).show());
                    logger("发送邀请失败，即将退出");
                    break;
            }
            mAgoraService.endCall();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onFirstRemoteFrame(int uid) {

        runOnUiThread(() -> {
            tvDuration.setVisibility(View.VISIBLE);
            mCallingTv.setVisibility(View.GONE);
            renderLayout.setForeground(null);
//            mSwitchIv.setVisibility(View.VISIBLE);
            mMicrophoneIv.setVisibility(View.GONE);
            mAvatarIv.setVisibility(View.INVISIBLE);
            ivVolume.setVisibility(View.VISIBLE);
            mAgoraService.setupRemoteVideo(renderLayout, uid);
            mAgoraService.startPreview();
            //mControlView.postDelayed(action, 5000);
        });
        if (mOriginalRaiseUpOn) {  //翻腕功能本身是开启的
            DeviceManager.getInstance().setRaiseUpValue(false);
        }
        if (mOriginalisOverlayScreenOn) {
            DeviceManager.getInstance().setOverlayScreenValue(false);
        }
    }


    @Override
    public void onUserJoined(int uid) {
        renderLayout.removeCallbacks(mInviteTasks);
        mUid = uid;
        isAnswer = true;
        stopRingtone();

        if (mIsVoiceCall) {
            runOnUiThread(() -> {
                tvDuration.setVisibility(View.VISIBLE);
                mMicrophoneIv.setVisibility(View.VISIBLE);
                ivVolume.setVisibility(View.VISIBLE);
                mCallingTv.setVisibility(View.GONE);
                mSwitchIv.setVisibility(View.GONE);
//                mControlView.postDelayed(action, 5000);
            });
        }
        if (mOriginalRaiseUpOn) {  //翻腕功能本身是开启的
            DeviceManager.getInstance().setRaiseUpValue(false);
        }
        if (mOriginalisOverlayScreenOn) {
            DeviceManager.getInstance().setOverlayScreenValue(false);
        }
    }


    @Override
    public void onTiming(int aLong) {
        try {
            runOnUiThread(() -> {
                long hour = TimeUnit.SECONDS.toHours(aLong);
                long minute = TimeUnit.SECONDS.toMinutes(aLong);
                tvDuration.setText(String.format(Locale.getDefault(), "%1$02d:%2$02d:%3$02d", hour, minute, aLong % TimeUnit.MINUTES.toSeconds(1)));
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onInviteRefused(String response) {
        if (response != null && response.contains("1000")) {
            runOnUiThread(() -> UToast.showCustomToast(OutgoingCallActivity.this, R.string.call_busy, Toast.LENGTH_LONG));
        }
        logger("对方拒绝接听，即将退出。");
        stopRingtone();
        mAgoraService.endCall();

    }

    @Override
    public void onInviteEnd() {
        logger("结束呼叫成功，退出应用");
        mAgoraService.endCall();
    }

    @Override
    public void onCallEnd(int totalDuration) {
        logger("视频通话结束>>>" + totalDuration);
        //插入通话记录
        final long endTime = System.currentTimeMillis();
        long startTime = endTime - TimeUnit.SECONDS.toMillis(totalDuration);
        if (totalDuration > 0) {

            CallLog.insert(peer, startTime, endTime, mIsVoiceCall ? InternalConstants.CallType.OUTGOING_VOIP_CALL : OUTGOING_VIDEO_CALL);
            if (totalDuration >= 30) {
                MMKV.defaultMMKV().putLong(friendId, SystemClock.elapsedRealtime());
            }
        }

        if (!isFinishing()) {
            finish();
        }
    }

    @Override
    public void onWarning(int warn) {
        Log.w("OutgoingCallActivity", "Contact RTC onWarning: " + warn);
    }

    @Override
    public void switch2VideoMode(int mode) {
        if (mode == 1) {
            //对方已同意
            runOnUiThread(() -> {
                isSwitch2Video = true;
                renderLayout.setForeground(null);
                mAgoraService.setupRemoteVideo(renderLayout, mUid);
            });
        }

    }

    @Override
    public void remoteVideoMuted() {
        //对方已停止推送视频流
        Logger.e("对方已停止推送视频流");

        runOnUiThread(() -> {
            if (renderLayout.getChildCount() > 0) {
                renderLayout.removeAllViews();
                mAgoraService.disableVideo();

                mIsVoiceCall = true;
                mAgoraService.setCallType(AgoraService.CALL_TYPE_VOICE);
                mAgoraService.sendSwitchMsg2Peer();
            }

            mSwitchIv.setVisibility(View.GONE);
            mMicrophoneIv.setVisibility(View.VISIBLE);
            ivVolume.setImageDrawable(mCurrentVolume == 0 ? ResourceManager.getInstance().getDrawable(R.drawable.ic_volume_mute) : ResourceManager.getInstance().getDrawable(R.drawable.ic_volume));
            mAvatarIv.setVisibility(TextView.VISIBLE);
//            final Drawable callTypeDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.contact_voice, null);
//            mCallingTv.setCompoundDrawablesRelativeWithIntrinsicBounds(callTypeDrawable, null, null, null);
//            mCallingTv.setVisibility(View.VISIBLE);

//            renderLayout.setBackground(ResourceManager.getInstance().getDrawable(R.drawable.voip_call_main_bg));
        });

    }

    @Override
    public void onPeerNoResponse() {//此回调在子线程
        //对方收到了呼叫邀请，但是没有应答
        logger("通知服务器取消邀请>>>" + (mIsVoiceCall ? notifyCancelVoip() : notifyCancelVideo()));
        mAgoraService.endCall();
    }


    @Override
    public void onInviteTimeout() { //此回调在子线程
        //连续呼叫对方3次
        logger("----------》呼叫失败");
        logger("通知服务器取消邀请>>>" + (mIsVoiceCall ? notifyCancelVoip() : notifyCancelVideo()));
    }

    @Override
    public void onNetworkQuality(int uid, int txQuality, int rxQuality) {
        if (txQuality == QUALITY_BAD || txQuality == QUALITY_VBAD || txQuality == QUALITY_DOWN
                || rxQuality == QUALITY_BAD || rxQuality == QUALITY_VBAD || rxQuality == QUALITY_DOWN) {
            if (BuildConfig.DEBUG) {
                try {
                    runOnUiThread(() -> UToast.show(getString(R.string.str_poor_connection), Toast.LENGTH_SHORT));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * 停止响铃
     */
    private void stopRingtone() {
        if (player != null && player.isPlaying()) {
            player.stop();
            player.reset();
            player.release();
            player = null;
        }
    }


    /**
     * 开始响铃
     */
    private void startRingtone() {
        try {
            stopRingtone();
            player = new MediaPlayer();
            Uri ringtone = mIsVoiceCall ? RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE) : getUriFromDrawableRes(this, R.raw.ringtone_call);
            player.setDataSource(this, ringtone);
            player.setAudioStreamType(AudioManager.STREAM_RING);
            player.setLooping(true);
            player.prepare();
            player.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 得到资源文件中图片的Uri
     *
     * @param context 上下文对象
     * @param id      资源id
     * @return Uri
     */
    public static Uri getUriFromDrawableRes(Context context, int id) {
        Resources resources = context.getResources();
        String path = ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
                + resources.getResourcePackageName(id) + "/"
                + resources.getResourceTypeName(id) + "/"
                + resources.getResourceEntryName(id);
        return Uri.parse(path);
    }

    @Override
    protected void registerUnbindAndDisableReceiver(boolean register) {

    }

    @Override
    public void onVolumeChanged(int volumeValue) {
        mCurrentVolume = volumeValue;
        if (volumeValue == 0) {
            ivVolume.setImageDrawable(mIsVoiceCall ? ResourceManager.getInstance().getDrawable(R.drawable.ic_volume_mute) : ResourceManager.getInstance().getDrawable(R.drawable.ic_volume_video_mute));
        } else {
            ivVolume.setImageDrawable(mIsVoiceCall ? ResourceManager.getInstance().getDrawable(R.drawable.ic_volume) : ResourceManager.getInstance().getDrawable(R.drawable.ic_volume_video));
        }
    }
}